package com.study.forumsystemproject.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.study.forumsystemproject.common.Result;
import com.study.forumsystemproject.common.ResultCode;
import com.study.forumsystemproject.exception.ApplicationException;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;
@Data
@Schema(name = "版块类", description = "描述论坛的版块信息")
@Slf4j
public class Board {
    private Long id;

    @Schema(description = "版块名称")
    private String name;

    @Schema(description = "文章数量", example = "100")
    private Integer articleCount;

    @Schema(description = "版块排序", example = "1")
    private Integer sort;

    @Schema(description = "版块状态", example = "1")
    private Integer state;

    @Schema(description = "删除标志", example = "0")
    private Integer deleteFlag;

    @Schema(description = "创建时间", example = "2024-01-01T12:00:00Z")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @Schema(description = "更新时间", example = "2024-01-02T12:00:00Z")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    public static void isBean(Integer state) {
        if(state != 0) {
            log.warn(ResultCode.FAILED_USER_BANNED.toString());
            throw new ApplicationException(Result.fail(ResultCode.FAILED_USER_BANNED));
        }
    }


}